/**
 * 
 */
package com.hezhi.trafficcopsys.service.impl;

import java.util.List;

import com.hezhi.framework.exception.APPException;
import com.hezhi.trafficcopsys.domain.BreakRuleRecord;
import com.hezhi.trafficcopsys.domain.SearchCondition;
import com.hezhi.trafficcopsys.domain.SpecialCar;
import com.hezhi.trafficcopsys.persistence.dao.BreakRuleRecordDao;
import com.hezhi.trafficcopsys.persistence.dao.SpecialCarDao;
import com.hezhi.trafficcopsys.persistence.dao.impl.BreakRuleRecordDaoImpl;
import com.hezhi.trafficcopsys.persistence.dao.impl.SpecialCarDaoImpl;
import com.hezhi.trafficcopsys.service.BreakRuleRecordService;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;

/**
 * @author wudo
 *
 */
public class BreakRuleRecordServiceImpl implements BreakRuleRecordService{
	
	private Logger log = LoggerFactory.getLogger(this.getClass());
	
	private BreakRuleRecordDao dao = new BreakRuleRecordDaoImpl();
	
	private SpecialCarDao specialCarDao = new SpecialCarDaoImpl();
	
	/**
	 * 
	 */
	@Override
	public List<BreakRuleRecord> searchByFile(String filepath,String carType,String startdate,String enddate) throws APPException{
		List<BreakRuleRecord> listRecords = null;
		try {
			List<SpecialCar> listSpecialCar = specialCarDao.getAllSpecialCar();
			//从DB中根据车牌号码查找违章记录信息
			listRecords = dao.searchForSpecialCar(listSpecialCar,carType,startdate,enddate);
		} catch (Exception e) {
			log.error("读取文件："+ filepath + "时出现错误！");
			throw new APPException("读取文件："+ filepath + "时出现错误！");
		} finally {
			
		}
		return listRecords;
	}

	/**
	 * 
	 */
	@Override
	public List<BreakRuleRecord> searchByCondition(SearchCondition searchCondition) throws APPException{
		return dao.searchForLikeCondition(searchCondition);
	}

	@Override
	public int deleteRecords(String[] breakRulePictureIDs) throws APPException {
		return dao.update(breakRulePictureIDs);
	}
	
	public byte[] showPicture(String pictureID) throws APPException{
		return dao.showPicture(pictureID);
	}
}
